package demo10.iterator.dinermergercafe;

import java.util.Iterator;



public class DinerMenu implements Menu {
	static final int MAX_ITEMS = 6;
int numberOfItems = 0;
MenuItem[] menuItems;//数组

public DinerMenu() {
	menuItems = new MenuItem[MAX_ITEMS];
	addItem("素食 番茄三明治",
			"(煎') 培根生菜 & 西红柿 用麦皮面包做", true, 2.99);
		addItem("番茄三明治",
			"哈根 和 生菜 & 西红柿 全麦面包", false, 2.99);
		addItem("例汤",
			"一天的汤，配一份土豆沙拉", false, 3.29);
		addItem("热狗",
			"热狗，酸菜，芝士。",false, 3.05);
		addItem("清蒸蔬菜加糙米",
			"糙米蒸蔬菜", true, 3.99);
		addItem("面食",
			"用蕃茄酱意大利面，和一片面包",true, 3.89);
}

public void addItem(String name, String description, 
                     boolean vegetarian, double price) 
{
	MenuItem menuItem = new MenuItem(name, description, vegetarian, price);
	if (numberOfItems >= MAX_ITEMS) {
		System.err.println("Sorry, menu is full!  Can't add item to menu");
	} else {
		menuItems[numberOfItems] = menuItem;
		numberOfItems = numberOfItems + 1;
	}
}

public MenuItem[] getMenuItems() {
	return menuItems;
}
//数组没有内置迭代器，自己创建
@Override
public Iterator<MenuItem> createIterator() {
	return new DinerMenuIterator(menuItems);
	//return new AlternatingDinerMenuIterator(menuItems);
}

// other menu methods here
}
